<script setup>
import {onMounted, onUnmounted, ref} from 'vue'
let timer = ref()
let tt
let t = () => {
  let d = new Date
  timer.value = d.toLocaleTimeString()
}
onMounted(() => {
  tt = setInterval(t, 1000)
})
onUnmounted(() => {
  clearInterval(tt)
})
</script>

<template>
  <h3>vue3 时钟效果：{{ timer }}</h3>
</template>

<style scoped>
h3{
  color:purple;
}
</style>
